import { createRouter, createWebHashHistory } from 'vue-router';

const routes = [
  {
    name: 'person',
    path: '/person',
    component: () => import('./view/person'),
    meta: {
      title: '添加人员',
    },
  },
  {
    name: 'poster',
    path: '/poster',
    component: () => import('./view/poster'),
    meta: {
      title: '海报',
    },
  },
];

const router = createRouter({
  routes,
  history: createWebHashHistory(),
});

router.beforeEach((to, from, next) => {
  const title = to.meta && to.meta.title;
  if (title) {
    document.title = title;
  }
  next();
});

export { router };
